package com.demo2do.fms.entity.vehicle.source;

import org.apache.commons.lang3.StringUtils;

import com.demo2do.core.utils.Alias;

/**
 *
 * @author Ark
 *
 */
@Alias("LockType")
public enum LockType {
    
    SHIPMENT_EXCEPTION("01", "调度异常锁定"),
    
    BUSINESS_EXCEPTION("02", "业务运作锁定"),
    
    TRANS_MANAGEMENT("03", "运力管理锁定"),
    
    FREEZE("04", "冻结"),
    
    SHIPMENT_OVERFLOW("05", "日调度超限");
    
    private String code;
    
    private String description;

    /**
     * @param code
     * @param description
     */
    private LockType(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    /**
     * @param code
     * @return
     */
    public static LockType codeOf(String code) {
    	
    	for (LockType lockType : LockType.values()) {
    		if (StringUtils.equals(lockType.getCode(), code)) {
    			return lockType;
    		}
		}
    	
    	return null;
    	
    }
    
    /**
     * @return
     */
    public boolean isShipmentException() {
        return this.equals(SHIPMENT_EXCEPTION);
    }
    
    /**
     * @return
     */
    public boolean isFreeze() {
    	return this.equals(FREEZE);
    }
    
    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }
    
}